import moment from 'moment';
// 命名规范：Arr普通枚举  field下拉字段枚举  Map表格字段枚举

// 表头筛选字段
const headerForm = {
  // 筛选栏
  headerFilter: [
    {
      prop: 'fundCode',
      type: 'select',
      label: '产品',
      filterable: true,
      clearable: true,
      optionDynamic: {
        apiKey: 'fundProOption',
        params: {},
        methods: 'post',
      },
      optionValue: 'fundCode',
      optionLabel: 'fundName',
      optionLabelText: ['fundName', 'fundCode'],
      width: 130,
      col: 8,
    },
  ],
};
// 表格字段
const tableColumn = {
  // 会员管理表格
  userTableMap: [
    {
      prop: 'id',
      label: 'ID',
      type: 'text',
    },
    {
      prop: 'userType',
      label: '用户类型',
      type: 'text',
      optionKey: 'USER_TYPE',
    },
    {
      prop: 'createBy',
      label: '创建者',
      type: 'text',
    },
    {
      prop: 'avatar',
      label: '头像',
      type: 'image',
    },
    {
      prop: 'nickname',
      label: '昵称',
      type: 'text',
    },
    {
      prop: 'realName',
      label: '姓名',
      type: 'text',
    },
    {
      prop: 'gender',
      label: '性别',
      type: 'text',
      tooltipText: '0:女 1:男 2:未知',
      optionKey: 'GENDER',
    },
    {
      prop: 'age',
      label: '年龄',
      type: 'text',
    },
    {
      prop: 'mobile',
      label: '手机号',
      type: 'text',
    },
    {
      prop: 'score',
      label: '积分',
      type: 'text',
    },
    {
      prop: 'joinTime',
      label: '加入时间',
      type: 'text',
      width: 160,
      tooltip: true,
    },
    {
      prop: 'joinIp',
      label: '加入IP',
      type: 'text',
    },

    {
      prop: 'status',
      label: '状态',
      type: 'text',
      tooltipText: '1:正常,0:隐藏',
      optionKey: 'COVERT_STATUS',
    },
  ],
  listedInProListMap: [
    {
      prop: 'fundName',
      label: '产品名称',
      type: 'linkText',
      tooltip: true,
      width: 180,
      action: 'hyperlink',
      customFormat: function (prop, value) {
        return value;
      },
      // 自定义表格cell样式
      customCellStyle: function ({ row, column, rowIndex, columnIndex }) {

      },
      // 自定义点击事件
      customClick: function (prop, action, { _this, scopeItem }) {

      },
    },
  ],
};
// 表单字段
const editForm = {
  // 会员管理筛选表单
  userFilterMap: [
    {
      prop: 'nickname',
      type: 'input',
      label: '昵称',
      clearable: true,
      width: 100,
      col: 0,
    },
    {
      prop: 'realName',
      type: 'input',
      label: '真实姓名',
      clearable: true,
      width: 100,
      col: 0,
    },
    {
      prop: 'gender',
      type: 'select',
      label: '性别',
      filterable: true,
      clearable: true,
      optionKey: 'GENDER',
      width: 100,
      col: 0,
    },
    {
      prop: 'mobile',
      type: 'input',
      label: '手机号',
      clearable: true,
      width: 100,
      col: 0,
    },
    {
      prop: 'userType',
      type: 'select',
      label: '用户类型',
      filterable: true,
      clearable: true,
      optionKey: 'USER_TYPE',
      width: 100,
      col: 0,
    },
    {
      prop: 'joinTimeStartTime',
      type: 'datePicker',
      dateType: 'date',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      label: '加入开始时间',
      clearable: true,
      width: 100,
      col: 0,
    },
    {
      prop: 'joinTimeEndTime',
      label: '加入结束时间',
      type: 'datePicker',
      dateType: 'date',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
      clearable: true,
      width: 100,
      col: 0,
    },
    {
      prop: 'status',
      type: 'select',
      label: '状态',
      clearable: true,
      filterable: true,
      optionKey: 'COVERT_STATUS',
      width: 100,
      col: 0,
    },
  ],
  // 会员管理新增/修改基本信息表单
  userBasicInfo: [
    {
      prop: 'userType',
      type: 'radio',
      label: '用户类型',
      optionKey: 'USER_TYPE',
      labelCustomClass: 'requiredFormItem',
      customClass: 'userTypeItem',
    },
    // {
    //   prop: 'createBy',
    //   type: 'input',
    //   label: '创建者',
    //   labelCustomClass: 'requiredFormItem',
    // },
    {
      prop: 'nickname',
      type: 'input',
      label: '昵称',
    },
    {
      prop: 'mobile',
      type: 'input',
      label: '注册手机号',
      labelCustomClass: 'requiredFormItem',
    },
    {
      prop: 'realName',
      type: 'input',
      label: '姓名',
      labelCustomClass: 'requiredFormItem',
    },
    {
      prop: 'gender',
      type: 'radio',
      label: '性别',
      optionKey: 'GENDER',
      labelCustomClass: 'requiredFormItem',
      customClass: 'genderItem',
    },
    {
      prop: 'addr',
      type: 'cascader',
      label: '所在地区',
      clearable: true,
      filterable: true,
      labelCustomClass: 'requiredFormItem',
      optionDynamic: {
        apiKey: 'AreaListOption',
        params: {},
        methods: 'get',
      },
      optionMode: 'tree',
      optionValue: 'id',
      optionLabel: 'name',
      optionChildName: 'chirdList',
    },
    {
      prop: 'status',
      type: 'select',
      label: '状态',
      clearable: true,
      filterable: true,
      labelCustomClass: 'requiredFormItem',
      optionKey: 'COVERT_STATUS',
    },
    {
      prop: 'birthday',
      type: 'datePicker',
      label: '出生日期',
      dateType: 'date',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      clearable: true,
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
    },
    {
      prop: 'height',
      type: 'input',
      label: '身高',
    },
    {
      prop: 'weight',
      type: 'input',
      label: '体重',
    },
    {
      prop: 'nationId',
      labelProp: 'nation',
      type: 'select',
      label: '民族',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'NationOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'nationName',
    },
    {
      prop: 'idCard',
      type: 'input',
      label: '身份证号',
    },
    {
      prop: 'salaryId',
      labelProp: 'salary',
      type: 'select',
      label: '年薪',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'SalaryOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'salaryName',
    },
    {
      prop: 'eduId',
      labelProp: 'edu',
      type: 'select',
      label: '学历',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'EduOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'eduName',
    },
    {
      prop: 'eduSchool',
      type: 'input',
      label: '毕业院校',
    },
    {
      prop: 'eduTypeId',
      type: 'select',
      label: '院校性质',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'EduTypeOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'eduTypeName',
    },
    {
      prop: 'constellationId',
      labelProp: 'constellation',
      type: 'select',
      label: '星座',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'ConstellationOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'constellationName',
    },
    {
      prop: 'zodiacId',
      labelProp: 'zodiac',
      type: 'select',
      label: '属相',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'ZodiacOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'zodiacName',
    },
    {
      prop: 'bloodTypeId',
      labelProp: 'bloodType',
      type: 'select',
      label: '血型',
      clearable: true,
      filterable: true,
      optionDynamic: {
        apiKey: 'BloodTypeOption',
        params: {},
        methods: 'get',
      },
      optionValue: 'id',
      optionLabel: 'bloodTypeName',
    },

    {
      prop: 'nativePlace',
      type: 'input',
      label: '籍贯',
      // linkOptionProp: 'addr',
      // optionDynamic: {
      //   apiKey: 'AreaListOption',
      //   params: {},
      //   methods: 'get',
      // },
      // optionMode: 'tree',
      // optionValue: 'id',
      // optionLabel: 'name',
      // optionChildName: 'chirdList',
    },
    {
      prop: 'joinTime',
      type: 'datePicker',
      label: '注册时间',
      clearable: true,
      dateType: 'date',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      pickerOptions: {
        disabledDate: function (time) {
          return time.getTime() > moment().format('x');
        },
      },
    },
    {
      prop: 'joinIp',
      type: 'input',
      label: '注册IP',
    },
  ],
};
// 其他映射
const otherMap = {
  // 认证信息
  userApproveInfo: [
    {
      approveId: 'real',
      approveType: '实名认证',
      approveFormName: 'faUserAuthenticationRealName',
      approveForm: [
        {
          prop: 'realName',
          type: 'input',
          label: '姓名',
        },
        {
          prop: 'idCard',
          type: 'input',
          label: '身份证号',
        },
      ],
      approvePhoto: [
        {
          prop: 'frontImage',
          type: 'upload',
          label: '身份证正面照',
          fileListProp: 'frontImageFileList',
        },
        {
          prop: 'backImage',
          type: 'upload',
          label: '身份证反面照',
          fileListProp: 'backImageFileList',
        },
      ],
      approveStatus: [
        {
          prop: 'auditStatus',
          type: 'radio',
          label: '认证类型',
          optionKey: 'APPROVE_STATUS',
        },
      ],
    },
    {
      approveId: 'edu',
      approveType: '学历认证',
      approveFormName: 'faUserAuthenticationEdu',
      approveForm: [
        {
          prop: 'eduId',
          type: 'select',
          label: '学历',
          clearable: true,
          filterable: true,
          optionDynamic: {
            apiKey: 'EduOption',
            params: {},
            methods: 'get',
          },
          optionValue: 'id',
          optionLabel: 'eduName',
        },
        {
          prop: 'eduTypeId',
          type: 'select',
          label: '院校性质',
          clearable: true,
          filterable: true,
          optionDynamic: {
            apiKey: 'EduTypeOption',
            params: {},
            methods: 'get',
          },
          optionValue: 'id',
          optionLabel: 'eduTypeName',
        },
        {
          prop: 'school',
          type: 'input',
          label: '毕业院校',
        },
      ],
      approvePhoto: [
        {
          prop: 'eduImages',
          type: 'upload',
          label: '毕业证/证明照',
          fileListProp: 'eduImagesFileList',
        },
      ],
      approveStatus: [
        {
          prop: 'auditStatus',
          type: 'radio',
          label: '认证类型',
          optionKey: 'APPROVE_STATUS',
        },
      ],
    },
    {
      approveId: 'salary',
      approveType: '收入认证',
      approveFormName: 'faUserAuthenticationSalary',
      approveForm: [
        {
          prop: 'salaryId',
          type: 'select',
          label: '收入',
          clearable: true,
          filterable: true,
          optionDynamic: {
            apiKey: 'SalaryOption',
            params: {},
            methods: 'get',
          },
          optionValue: 'id',
          optionLabel: 'salaryName',
        },
        {
          prop: 'salaryRemark',
          type: 'input',
          label: '说明',
        },
      ],
      approvePhoto: [
        {
          prop: 'salaryImages',
          type: 'upload',
          label: '收入证明',
          fileListProp: 'salaryImagesFileList',
        },
      ],
      approveStatus: [
        {
          prop: 'auditStatus',
          type: 'radio',
          label: '认证类型',
          optionKey: 'APPROVE_STATUS',
        },
      ],
    },
    {
      approveId: 'car',
      approveType: '车辆认证',
      approveFormName: 'faUserAuthenticationCar',
      approveForm: [
        {
          prop: 'carStatus',
          type: 'select',
          label: '购车状态',
          clearable: true,
          filterable: true,
          optionkey: 'CAR_STATUS',
        },
        {
          prop: 'carRemark',
          type: 'input',
          label: '购车想法',
        },
      ],
      approvePhoto: [
        {
          prop: 'carImages',
          type: 'upload',
          label: '驾驶证正面照',
          fileListProp: 'carImagesFileList',
        },
      ],
      approveStatus: [
        {
          prop: 'auditStatus',
          type: 'radio',
          label: '认证类型',
          optionKey: 'APPROVE_STATUS',
        },
      ],
    },
    {
      approveId: 'house',
      approveType: '房产认证',
      approveFormName: 'faUserAuthenticationHouse',
      approveForm: [
        {
          prop: 'houseStatus',
          type: 'select',
          label: '购房状态',
          clearable: true,
          filterable: true,
          optionkey: 'HOUSE_STATUS',
        },
        {
          prop: 'houseRemark',
          type: 'input',
          label: '购房想法',
        },
      ],
      approvePhoto: [
        {
          prop: 'houseImages',
          type: 'upload',
          label: '房产证/购房合同',
          fileListProp: 'houseImagesFileList',
        },
      ],
      approveStatus: [
        {
          prop: 'auditStatus',
          type: 'radio',
          label: '审核状态',
          optionKey: 'APPROVE_STATUS',
        },
      ],
    },
  ],
};
// 表单字段校验
const editRule = {
  userBasicRule: {
    createBy: [{ required: true, message: '创建者不能为空', trigger: 'blur' }],
    gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
    addr: [{ required: true, message: '请选择所在地区', trigger: 'change' }],
    realName: [{ required: true, message: '用户真实姓名不能为空', trigger: 'blur' }],
    mobile: [{ required: true, message: '手机号码不能为空', trigger: 'blur' }],
    userType: [{ required: true, message: '请选择用户类型', trigger: 'change' }],
    status: [{ required: true, message: '请选择状态', trigger: 'change' }],
  },
};
export default {
  headerForm,
  tableColumn,
  editForm,
  otherMap,
  editRule,
};
